<?php View::render('admin/layouts/meta');?>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 商品评论管理
    <span class="c-gray en">&gt;</span> 商品评论列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
        <i class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>
<div class="page-container">
    <form>
        <div class="text-c">
             <span class="select-box" style="width:120px">
                <select name="status" class="select">
                    <option value="">评论状态</option>
                    <option value="1" <?php if ($status == 1) {echo 'selected="selected"';}?>>未审核</option>
                    <option value="2" <?php if ($status == 2) {echo 'selected="selected"';}?>>已审核</option>
                    <option value="3" <?php if ($status == 3) {echo 'selected="selected"';}?>>屏蔽</option>
                </select>
            </span>
            <input type="text" class="input-text" style="width:200px" placeholder="帖子内容" name="keyword" value="<?php echo $keyword; ?>">
            <input type="text" class="input-text" style="width:200px" name="uid" value="<?php echo $uid; ?>" placeholder="评论用户UID"/>
            <input type="text" class="input-text" style="width:200px" name="typeId" value="<?php echo $typeId; ?>" placeholder="商品ID"/>
            <input type="hidden" name="page" value="1"/>
            <button type="submit" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
        </div>
    </form>
	<div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
        </span>
        <span class="r">共有数据：<strong><?php echo $total; ?></strong> 条</span>
    </div>
	<div class="mt-20">
	<table class="table table-border table-bordered table-hover table-bg table-sort">
		<thead>
			<tr class="text-c">
				<th width="50">ID</th>
                <th>评论用户</th>
                <th  width="300">内容</th>
                <th  width="200">商品</th>
                <th>图片</th>
                <th>评分</th>
				<th width="100">添加时间</th>
				<th width="200">操作</th>
			</tr>
		</thead>
		<tbody>
            <?php if ($list) {
	foreach ($list as $info) {
		?>
			<tr class="text-c">
				<td><?php echo $info['comment_id']; ?></td>
                <td class="text-l"><a href="javascript:;" style="text-decoration:none"  onclick="formAlert('查看详情','<?php echo Router::getBaseUrl(); ?>/admin_user/view?uid=<?php echo $info['uid']; ?>', '100%','100%')"><?php echo $info['nickname']; ?></a></td>
                <td class="text-l"><?php echo $info['content']; ?></td>
                <td class="text-l"><?php echo $info['goods_title']; ?></td>
                <td class="text-l">
                    <?php if ($info['image_list']) {
			$imageList = explode(';', $info['image_list']);
			foreach ($imageList as $image) {?>
                    <img src="<?php echo $image; ?>" class="thumbnail mr-5" style="width:60px;height:60px;"/>
                <?php }}?>
                </td>
                <td><?php echo $info['score']; ?></td>
				<td><?php echo date('Y-m-d H:i', $info['add_time']); ?></td>
				<td class="td-manage">
                    <a href="javascript:;" style="text-decoration:none"  onclick="formAlert('编辑评论','<?php echo Router::getBaseUrl(); ?>/admin_comment/edit?commentId=<?php echo $info['comment_id']; ?>', '100%','100%')"  class="j_edit ml-5">编辑</a>
                    <a href="javascript:;" style="text-decoration:none"  class="j_del ml-5" rel="<?php echo $info['comment_id']; ?>">删除</a>
                </td>
			</tr>
            <?php }}?>
		</tbody>
	</table>
        <div>
            <?php echo $pageHtml; ?>
        </div>
	</div>
</div>
</body>
<?php View::render('admin/layouts/footer');?>
<script type="text/javascript">
$(function(){
    window.formAlert = function(title, url, w, h) {
        layer.open({
            type: 2,
            title: title,
            area: [w, h],
            content: url,
            end: function(){
               window.location.href=location.href;
            }
          });
    }
    $('.j_del').click(function(){
        var id = $(this).attr('rel');
        $.post('<?php echo Router::getBaseUrl(); ?>/admin_comment/delete', {commentId:id}, function (result) {
                if (result.status == 200) {
                    layer.msg(result.msg, {
                        icon: 1,
                        skin: 'u-msg',
                        time: 1800,
                    },function() {
                        window.location.href = location.href;
                        return true;
                    });
                }else{
                    layer.msg(result.msg, {
                        icon: 0,
                        skin: 'u-msg',
                        time: 2200,
                    });
                }
            }, 'json');
        return;
    });
    $('.j_audit,.j_live').click(function(){
        var id = $(this).attr('rel');
        $.post('<?php echo Router::getBaseUrl(); ?>/admin_comment/status', {commentId:id,status:1}, function (result) {
                if (result.status == 200) {
                    layer.msg(result.msg, {
                        icon: 1,
                        skin: 'u-msg',
                        time: 1800,
                    },function() {
                        window.location.href = location.href;
                        return true;
                    });
                }else{
                    layer.msg(result.msg, {
                        icon: 0,
                        skin: 'u-msg',
                        time: 2200,
                    });
                }
            }, 'json');
        return;
    });
    $('.j_slide').click(function(){
        var id = $(this).attr('rel');
        $.post('<?php echo Router::getBaseUrl(); ?>/admin_comment/status', {commentId:id,status:2}, function (result) {
                if (result.status == 200) {
                    layer.msg(result.msg, {
                        icon: 1,
                        skin: 'u-msg',
                        time: 1800,
                    },function() {
                        window.location.href = location.href;
                        return true;
                    });
                }else{
                    layer.msg(result.msg, {
                        icon: 0,
                        skin: 'u-msg',
                        time: 2200,
                    });
                }
            }, 'json');
        return;
    });
});
</script>
</html>